<include file="public@header"/>
<script type="text/html" id="photos-item-tpl">
    <li id="saved-image{id}">
        <input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
        <input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
               style="width: 200px;" title="图片名称">
        <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
             onclick="imagePreviewDialog(this.src);">
        <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
        <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
    </li>
</script>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('Course/index')}">课程管理</a></li>
        <li class="active"><a href="">编辑</a></li>
    </ul>
    <form action="{:url('Course/edit')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
        <div class="row">
            <div class="col-md-9">
                <input type="hidden" name="course_id" value="{$course_id}">
                <table class="table table-bordered">
                    <tr>
                        <th width="15%">分类<span class="form-required">*</span></th>
                        <td>
                            <select class="form-control" name="cate_id">
                                <option value="">请选择分类</option>
                                <foreach name="cateList" item="c">
                                    <option value="{$c.cate_id}" <if condition="$cate_id eq $c['cate_id']">selected</if>>{$c.cate_name}</option>
                                </foreach>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th width="15%">选择机构<span class="form-required">*</span></th>
                        <td>
                            <select class="form-control" name="admin_id" id="userList">
                                <option value="">请选择机构</option>
                                <foreach name="userList" item="c">
                                    <option value="{$c.id}" <if condition="$admin_id eq $c['id']">selected</if>>{$c.user_nickname}</option>
                                </foreach>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>课程名称<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control" type="text" value="{$course_name}" name="course_name" placeholder="请输入课程名称"/>
                        </td>
                    </tr>
                    <tr>
                        <th>价格<span class="form-required">*</span></th></th>
                        <td>
                            <input class="form-control" type="number" name="price" value="{$price}"/>
                        </td>
                    </tr>
                    <tr>
                        <th>库存数<span class="form-required">*</span></th></th>
                        <td>
                            <input class="form-control" type="number" name="sku" value="{$sku}"/>
                        </td>
                    </tr>
                    <tr>
                        <th>团购价格<span class="form-required">*</span></th></th>
                        <td>
                            <input class="form-control" type="number" name="assemble_price" value="{$assemble_price}"/>
                        </td>
                    </tr>
                    <tr>
                        <th>分佣比例<span class="form-required">*</span></th></th>
                        <td>
                            <input class="form-control" type="number" name="proportion" value="{$proportion}"/>
                        </td>
                    </tr>
                    <tr>
                        <th>团购人数<span class="form-required">*</span></th></th>
                        <td>
                            <input class="form-control" type="number" name="total_num" value="{$total_num}"/>
                        </td>
                    </tr>
                    <tr>
                        <th>团购结束时间<span class="form-required">*</span></th></th>
                        <td>
                            <input class="form-control js-bootstrap-datetime" type="text" name="end_time"
                                   value="{:date('Y-m-d H:i:s',$end_time)}">
                        </td>
                    </tr>

                    <tr>
                        <th>摘要</th>
                        <td>
                            <textarea class="form-control" name="desc" style="height: 50px;"
                                      placeholder="请填写摘要">{$desc}</textarea>
                        </td>
                    </tr>
                    <tr>
                        <th>内容</th>
                        <td>
                            <script type="text/plain" id="content" name="content">{$content}</script>
                        </td>
                    </tr>

                    <!--
                    <tr>
                        <th>附件</th>
                        <td>
                            <ul id="files" class="pic-list list-unstyled form-inline">
                            </ul>
                            <a href="javascript:uploadMultiFile('附件上传','#files','files-item-tpl','file');"
                               class="btn btn-sm btn-default">选择文件</a>
                        </td>
                    </tr>
                    <tr>
                        <th>音频</th>
                        <td class="form-inline">
                            <input id="file-audio" class="form-control" type="text" name="post[more][audio]"
                                   value="" placeholder="请上传音频文件" style="width: 200px;">

                            <a href="javascript:uploadOne('文件上传','#file-audio','audio');">上传</a>
                        </td>
                    </tr>
                    <tr>
                        <th>视频</th>
                        <td class="form-inline">
                            <input id="file-video" class="form-control" type="text" name="post[more][video]"
                                   value="" placeholder="请上传视频文件" style="width: 200px;">
                            <a href="javascript:uploadOne('文件上传','#file-video','video');">上传</a>
                        </td>
                    </tr>-->
                </table>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-primary js-ajax-submit">保存</button>
                        <a class="btn btn-default" href="javascript:history.back(-1)">返回</a>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <table class="table table-bordered">
                    <tr>
                        <th><b>缩略图</b></th>
                    </tr>
                    <tr>
                        <td>
                            <div style="text-align: center;">
                                <input type="hidden" name="image" id="thumb" value="{$image|default=''}">
                                <a href="javascript:uploadOneImage('图片上传','#thumb');">
                                    <if condition="empty($image)">
                                        <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                             id="thumb-preview" width="135" style="cursor: hand"/>
                                        <else/>
                                        <img src="{:cmf_get_image_preview_url($image)}" id="thumb-preview"
                                             width="135" style="cursor: hand"/>
                                    </if>
                                </a>
                                <input type="button" class="btn btn-sm"
                                       onclick="$('#thumb-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#thumb').val('');return false;"
                                       value="取消图片">
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th>相册</th>

                    </tr>
                    <tr>
                        <td>
                            <ul id="photos" class="pic-list unstyled">
                                <notempty name="$photosList">
                                    <foreach name="$photosList" item="vo">
                                        <li id="savedimage{$key}">
                                            <input id="photo-{$key}" type="hidden" name="photos_url[]" value="{$vo.path}">
                                            <input id="photo-{$key}-name" type="text" name="photos_alt[]" value="{:trim(strrchr($vo['path'], '/'),'/');}" title="图片名称">
                                            <img id="photo-{$key}-preview" src="{:cmf_get_image_preview_url($vo.path)}" style="height:36px;width: 36px;" onclick="parent.image_preview_dialog(this.src);">
                                            <a href="javascript:upload_one_image('图片上传','#photo-{$key}');">替换</a>
                                            <a href="javascript:(function(){ $('#savedimage{$key}').remove();})();">移除</a>
                                        </li>
                                    </foreach>
                                </notempty>
                            </ul>
                            <a href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');"
                               class="btn btn-default btn-sm">选择图片</a>
                        </td>
                    </tr>
                </table>

            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="/static/js/admin.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="/static/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/static/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
    $(function () {

        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {
        }
    })
</script>
</body>
</html>
